﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using _180FrameWork.CustControls.Models;

namespace _180FrameWork.CustControls
{
    public partial class CustQueryPanel : UserControl
    {       
        public CustQueryPanel()
        {
            InitializeComponent();             
        }

        public void AddCustQueryCondition(string PName,string DisPlay)
        {
            var lb = new CustQueryLabel(PName, DisPlay);
            lb.Closed += new EventHandler(lb_Closed);
            this.Controls.Add(lb);
            if (this.HorizontalScroll.Visible)
            {
                this.Height = 55;
            }
            OnQCAdded(lb, new EventArgs());
        }

        void lb_Closed(object sender, EventArgs e)
        {
            var lb = sender as CustQueryLabel;
            this.Controls.Remove(lb);
            if (!this.HorizontalScroll.Visible)
            {
                this.Height = 26;
            }
            OnQCRemoveed(lb, new EventArgs());
        }

        /// <summary>
        /// 增加一个查询条件时候
        /// </summary>
        [Category("Data")]
        [Description("CustFilterPanel_QCAdded")]
        public event EventHandler QCAdded;

        // 执行事件
        protected virtual void OnQCAdded(object sender, EventArgs e)
        {
            if (QCAdded != null)
            {
                QCAdded(sender, e);
            }
        }

        /// <summary>
        /// 去掉一个查询条件时候
        /// </summary>
        [Category("Data")]
        [Description("CustFilterPanel_QCRemoveed")]
        public event EventHandler QCRemoveed;

        // 执行事件
        protected virtual void OnQCRemoveed(object sender, EventArgs e)
        {
            if (QCRemoveed != null)
            {
                QCRemoveed(sender, e);
            }
        }
    }
}
